package com.qjquestion.exceptions;

import com.qjquestion.model.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    //自定义异常处理
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result error(BusinessException exception) {
        return Result.fail(exception.getMessage());
    }
}
